﻿using NUnit.Framework;

namespace BowlingGame
{
    [TestFixture]
    public class GameScoreShould
    {
        #region Snip
        [SetUp]
        public void SetUp()
        {
            _game = new Game();
        }

        private Game _game;

        private void RollMany(int times, int pins)
        {
            for (int i = 0; i < times; i++)
            {
                _game.Roll(pins);
            }
        }

        private void RollSpare()
        {
            RollMany(2, 5);
        }

        private void RollStrike()
        {
            _game.Roll(10);
        }
        #endregion

        [Test]
        public void ReturnZeroGivenGutterGame()
        {
            RollMany(20, 0);
            Assert.AreEqual(0, _game.Score());
        }

        [Test]
        public void ReturnTwentyGivenAllOnes()
        {
            RollMany(20, 1);
            Assert.AreEqual(20, _game.Score());
        }

        [Test]
        public void ReturnSixteenGivenSpareFollowedByThree()
        {
            RollSpare();
            _game.Roll(3);
            Assert.AreEqual(16, _game.Score());
        }

        [Test]
        public void ReturnFourteenGivenStrikeFollowedByTwoOnes()
        {
            RollStrike();
            RollMany(2, 1);
            Assert.AreEqual(14, _game.Score());
        }

        [Test]
        public void Return300GivenPerfectGame()
        {
            RollMany(12, 10);
            Assert.AreEqual(300, _game.Score());
        }

    }
}
